package com.jfs.security.authentication;

import com.jfs.entity.Role;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.userdetails.User;

import java.util.List;

/**
 * @Description jwt用户封装
 * @E-mail cwm3412638@163.com
 * @Author cwm
 * @Date 2022/8/5
 */
@Getter
@Setter
public class JwtUser extends User {
    private String id;
    private String roleId;
    private String phone;
    private String nickName;
    private Role role;
    private String username;
    private String password;
    private List<GrantedAuthorityImpl> authority;
    private Boolean enabled;

    public JwtUser(String id, String roleId, String phone, String nickName, Role role, String username, String password, List<GrantedAuthorityImpl> authorities) {
        super(username, password, authorities);
        this.id = id;
        this.roleId = roleId;
        this.phone = phone;
        this.nickName = nickName;
        this.role = role;
        this.username = username;
        this.password = password;
        this.enabled = true;
        this.authority = authorities;
    }

    public JwtUser(String id, String roleId, String phone, String nickName, Role role, String username, String password, boolean enabled, List<GrantedAuthorityImpl> authorities) {
        super(username, password, enabled, true, true, true, authorities);
        this.id = id;
        this.roleId = roleId;
        this.phone = phone;
        this.nickName = nickName;
        this.role = role;
        this.username = username;
        this.password = password;
        this.enabled = enabled;
        this.authority = authorities;
    }
}
